package routers

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/plugins/cors"
	"controllers"
)

func init() {

	apiNs := beego.NewNamespace("/v1",
		beego.NSNamespace("/file",
			beego.NSInclude(
				&controllers.FileApi{},
			),
		),
	)
	beego.AddNamespace(apiNs)

	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
		AllowAllOrigins:  true,
		AllowMethods:     []string{"*"},
		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin"},
		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin"},
		AllowCredentials: true,
	}))

}
